/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opgea.token.domain.entities;

import java.io.Serializable;
import java.math.BigInteger;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import com.opgea.token.domain.qualifiers.TokenStatusQualifier;

/**
 * 
 * @author Ramesh
 */
@Entity
@Table(name = "tokendetails")
@XmlRootElement
@NamedQueries({
	@NamedQuery(name = "TokenDetails.findAll", query = "SELECT t FROM TokenDetails t"),
	@NamedQuery(name = "TokenDetails.findById", query = "SELECT t FROM TokenDetails t WHERE t.id = :id"),
	@NamedQuery(name = "TokenDetails.findByEmailId", query = "SELECT t FROM TokenDetails t WHERE t.emailId = :emailId"),
	@NamedQuery(name = "TokenDetails.findByMobileNo", query = "SELECT t FROM TokenDetails t WHERE t.mobileNo = :mobileNo"),
	@NamedQuery(name = "TokenDetails.findByName", query = "SELECT t FROM TokenDetails t WHERE t.name = :name"),
	@NamedQuery(name = "TokenDetails.findAllByCompanyId", query = "SELECT t FROM TokenDetails t WHERE t.token.company.id = :companyId"),
	@NamedQuery(name = "TokenDetails.findAllByDestination", query = "SELECT t FROM TokenDetails t WHERE t.token.company.id = :companyId  and t.destination.id = :destinationId") })
public class TokenDetails implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id")
    private Long id;

    @Column(name = "emailId")
    private String emailId;

    @Column(name = "mobileNo")
    private BigInteger mobileNo;

    @Column(name = "name")
    private String name;

    @JoinColumn(name = "token_id", referencedColumnName = "id")
    @OneToOne
    private Token token;

    @JoinColumn(name = "destination_id", referencedColumnName = "id")
    @ManyToOne
    private Destination destination;

    @Column(name = "tokenStatus")
    private TokenStatusQualifier tokenStatus;

    @Column(name = "metaData")
    private String metaData;

    public TokenDetails() {
    }

    public TokenDetails(Long id) {
	this.id = id;
    }

    public Long getId() {
	return id;
    }

    public void setId(Long id) {
	this.id = id;
    }

    public String getEmailId() {
	return emailId;
    }

    public void setEmailId(String emailId) {
	this.emailId = emailId;
    }

    public BigInteger getMobileNo() {
	return mobileNo;
    }

    public void setMobileNo(BigInteger mobileNo) {
	this.mobileNo = mobileNo;
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public Token getToken() {
	return token;
    }

    public void setToken(Token token) {
	this.token = token;
    }

    public Destination getDestination() {
	return destination;
    }

    public void setDestination(Destination destination) {
	this.destination = destination;
    }

    public TokenStatusQualifier getTokenStatus() {
	return tokenStatus;
    }

    public void setTokenStatus(TokenStatusQualifier tokenStatus) {
	this.tokenStatus = tokenStatus;
    }

    public String getMetaData() {
	return metaData;
    }

    public void setMetaData(String metaData) {
	this.metaData = metaData;
    }

    @Override
    public int hashCode() {
	int hash = 0;
	hash += (id != null ? id.hashCode() : 0);
	return hash;
    }

    @Override
    public boolean equals(Object object) {
	if (!(object instanceof TokenDetails)) {
	    return false;
	}
	TokenDetails other = (TokenDetails) object;
	if ((this.id == null && other.id != null)
		|| (this.id != null && !this.id.equals(other.id))) {
	    return false;
	}
	return true;
    }

    @Override
    public String toString() {
	return "TokenDetails [id=" + id + ", emailId=" + emailId
		+ ", mobileNo=" + mobileNo + ", name=" + name + ", token="
		+ token + ", destination=" + destination + ", tokenStatus="
		+ tokenStatus + ", metaData=" + metaData + "]";
    }

}
